ALTER COMMAND



MySQL - Alter Command


The ALTER command is used to modify the existing table.
It involves adding,removing,modifying,creating,dropping,renaming,changing the engine,changing the collation of table or some columns.


SYNTAX :

ALTER TABLE table_name
  ADD new_column_name column_definition
    [ FIRST | AFTER column_name ];

Lets consider a table and check how alter command is performing :


IDNameAddressCompanySalary
1NihariHabsigudaDELL25000
2SwaraMadhapurHCL35000
3LaraSR nagarXIUS54000
4KiaraKPHBGOOGLE64000
5HarshadGachibowliHP48000

Adding a new column :


ALTER TABLE employeerecord
  ADD Gender varchar(55) NOT NULL
    AFTER Salary;

Result will be displayed as follows:


IDNameAddressCompanySalaryGender
1NihariHabsigudaDELL25000-

Removing a column from the existing table:


ALTER TABLE employeerecord DROP Column Gender;

Result will be displayed as follows:


IDNameAddressCompanySalary
1NihariHabsigudaDELL25000

Modifying the data type, name, default values of a column in the existing table :


ALTER TABLE  employeerecord
CHANGE COLUMN Salary  Compensation
Int(55) NOT NULL;  

Result will be displayed as follows :
IDNameAddressCompanyCompensation
1NihariHabsigudaDELL25000


MySQL TRIGGERS

MySQL - Triggers

posted on 2019-11-29 21:44:07 - mysql Tutorials


Grant_ Revoke Privilege

MySQL - Grant_ Revoke Privilege

posted on 2019-11-26 23:15:04 - mysql Tutorials


MySQL Vs SQL

MySQL Vs SQL

posted on 2019-11-25 05:02:26 - mysql Tutorials


Prompt Examples

ChatGPT Prompt Examples

posted on 2023-06-21 22:37:19 - ChatGPT Tutorials


Use Cases

Chat GPT Key Use Cases

posted on 2023-06-21 21:03:17 - ChatGPT Tutorials


Prompt Frameworks

Prompt Frameworks

posted on 2023-06-21 19:33:06 - ChatGPT Tutorials